#include <stdio.h>
#include <time.h>

#define LDBG 0
#define LINF  1
#define LERR  2

#define LDEFAULT LINF

#define LOG(level, format, ...) {\
    if (level >= LDEFAULT) {\
        time_t t = time(NULL);\
        struct tm* lt = localtime(&t);\
        char time_str[32];\
        strftime(time_str, 31, "%Y-%m-%d %H:%M:%S",lt);\
        fprintf(stdout, "[%s] %s:%d:" format "\n", time_str, __FILE__, __LINE__, ##__VA_ARGS__);\
    }\
}

#define DLOG(format,...) LOG(LDBG, format, ##__VA_ARGS__);
#define DINF(format,...) LOG(LINF, format, ##__VA_ARGS__);
#define DERR(format,...) LOG(LERR, format, ##__VA_ARGS__);
    

int main() {
    DLOG("hello world");
    DINF("hello world");
    DERR("hello world");
    return 0;
}